'''
Created on Dec 3, 2012

@author: quirino
'''
import unittest
import cupy
from cupy.session import Session

class Test(unittest.TestCase):


    def test_get_no_session(self):
        resp = cupy.get("http://localhost:8000")
        self.assertIsNotNone(resp, "Unable to query from main interface")
    
    def test_get_provided_session(self):
        session = Session()
        self.assertFalse(session.is_closed(), 
                         "Session declared close after construction")
        resp = cupy.get(url="http://localhost:8000", session=session)
        self.assertIsNotNone(resp, "Unable to query from main interface")
        self.assertFalse(session.is_closed(), 
                         "CuPy is closing provided session")
        session.close()
        self.assertTrue(session.is_closed(), 
                         "Session not correctly closed")
    
    def test_head_no_session(self):
        resp = cupy.head(url="http://localhost:8000")
        self.assertIsNotNone(resp, "Unable to query from main interface")

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.test_get']
    unittest.main()